package com.bitoon.basketdudes.web.jpa;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;;

/**
 *
 * @author paco
 */
@Entity
@Table(name = "carta", schema = "basket")
@NamedQueries({
    @NamedQuery(name = "Carta.findAll"          , query = "SELECT c FROM Carta c order by mCarta.id,c.categoriaId"),
    @NamedQuery(name = "Carta.findActivas"      , query = "SELECT c FROM Carta c WHERE (estado=1 or estado=2 or estado=3) order by id"),
    @NamedQuery(name = "Carta.findTienda"       , query = "SELECT c FROM Carta c where estado>0 order by mCarta.id,c.nivel,c.categoriaId"),
    @NamedQuery(name = "Carta.findServidor"     , query = "SELECT c FROM Carta c where estado>0 order by mCarta.id,c.nivel,c.categoriaId"),
//    @NamedQuery(name = "Carta.findAll", query = "SELECT c FROM Carta c "),
    @NamedQuery(name = "Carta.findById"         , query = "SELECT c FROM Carta c WHERE c.id = :id"),
    @NamedQuery(name = "Carta.findByRareza"     , query = "SELECT c FROM Carta c WHERE c.rareza = :rareza"),
    @NamedQuery(name = "Carta.findByChestBall"  , query = "SELECT c FROM Carta c WHERE (estado=1 or estado=2) and c.rareza = :rareza and c.categoriaId= :nivel"),
    @NamedQuery(name = "Carta.findBySobre"      , query = "SELECT c FROM Carta c WHERE (estado=1 or estado=2 or estado=3) and c.rareza = :rareza and c.categoriaId= :nivel"),

    @NamedQuery(name = "Carta.findByCategoriaId", query = "SELECT c FROM Carta c WHERE c.categoriaId = :categoriaId"),
    @NamedQuery(name = "Carta.findByPrecio"     , query = "SELECT c FROM Carta c WHERE c.precio = :precio"),
    @NamedQuery(name = "Carta.findByPuntos"     , query = "SELECT c FROM Carta c WHERE c.puntos = :puntos"),
    @NamedQuery(name = "Carta.findByNivel"      , query = "SELECT c FROM Carta c WHERE c.nivel = :nivel"),
    @NamedQuery(name = "Carta.findByStockTotal" , query = "SELECT c FROM Carta c WHERE c.stockTotal = :stockTotal"),
    @NamedQuery(name = "Carta.findByVendidas"   , query = "SELECT c FROM Carta c WHERE c.vendidas = :vendidas"),
    @NamedQuery(name = "Carta.findByDevueltas"  , query = "SELECT c FROM Carta c WHERE c.devueltas = :devueltas"),
    @NamedQuery(name = "Carta.findByFIni"       , query = "SELECT c FROM Carta c WHERE c.fIni = :fIni"),
    @NamedQuery(name = "Carta.findByFFin"       , query = "SELECT c FROM Carta c WHERE c.fFin = :fFin"),
    @NamedQuery(name = "Carta.findByUdsEquipo"  , query = "SELECT c FROM Carta c WHERE c.udsEquipo = :udsEquipo"),
    @NamedQuery(name = "Carta.findByEstado"     , query = "SELECT c FROM Carta c WHERE c.estado = :estado"),
    @NamedQuery(name = "Carta.findByResumen"    , query = "SELECT c FROM Carta c WHERE c.resumen = :resumen"),
    @NamedQuery(name = "Carta.findByDuracion"   , query = "SELECT c FROM Carta c WHERE c.duracion = :duracion"),
    @NamedQuery(name = "Carta.findByCuartos"    , query = "SELECT c FROM Carta c WHERE c.cuartos = :cuartos")})
public class Carta implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "rareza")
    private int rareza;
    @Basic(optional = false)
    @Column(name = "categoria_id")
    private int categoriaId;
    @Basic(optional = false)
    @Column(name = "precio")
    private float precio;
    @Basic(optional = false)
    @Column(name = "puntos")
    private int puntos;
    @Basic(optional = false)
    @Column(name = "nivel")
    private short nivel;
    @Column(name = "stock_total")
    private Integer stockTotal;
    @Column(name = "vendidas")
    private Integer vendidas;
    @Column(name = "devueltas")
    private Integer devueltas;
    @Column(name = "f_ini")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fIni;
    @Column(name = "f_fin")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fFin;
    @Column(name = "uds_equipo")
    private Short udsEquipo;
    @Column(name = "estado")
    private Short estado;
    @Column(name = "resumen")
    private String resumen;
    @Column(name = "duracion")
    private String duracion;
    @Basic(optional = false)
    @Column(name = "cuartos")
    private short cuartos;
    @Column(name = "descripcion")
    private String descripcion;

    @ManyToOne(optional = false)
    @JoinColumn(name = "m_carta_id", referencedColumnName = "id")
    private MCarta mCarta;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "carta")
    private Collection<CartaEquipo> cartaEquipoCollection;
//    @OneToMany(cascade = CascadeType.ALL, mappedBy = "carta")
//    private Collection<Mazo> mazoCollection;
    @Column(name = "efecto_tipo")
    private int     efecto_tipo;
    @Column(name = "efecto_valor")
    private int     efecto_valor;

    public Carta() {
    }

    public Carta(Integer id) {
        this.id = id;
    }

    public Carta(Integer id, int rareza, int categoriaId, float precio, int puntos, short nivel, short cuartos) {
        this.id = id;
        this.rareza = rareza;
        this.categoriaId = categoriaId;
        this.precio = precio;
        this.puntos = puntos;
        this.nivel = nivel;
        this.cuartos = cuartos;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public int getRareza() {
        return rareza;
    }

    public void setRareza(int rareza) {
        this.rareza = rareza;
    }

    public int getCategoriaId() {
        return categoriaId;
    }

    public void setCategoriaId(int categoriaId) {
        this.categoriaId = categoriaId;
    }

    public float getPrecio() {
        return precio;
    }

    public void setPrecio(float precio) {
        this.precio = precio;
    }

    public int getPuntos() {
        return puntos;
    }

    public void setPuntos(int puntos) {
        this.puntos = puntos;
    }

    public short getNivel() {
        return nivel;
    }

    public void setNivel(short nivel) {
        this.nivel = nivel;
    }

    public Integer getStockTotal() {
        return stockTotal;
    }

    public void setStockTotal(Integer stockTotal) {
        this.stockTotal = stockTotal;
    }

    public Integer getVendidas() {
        return vendidas;
    }

    public void setVendidas(Integer vendidas) {
        this.vendidas = vendidas;
    }

    public Integer getDevueltas() {
        return devueltas;
    }

    public void setDevueltas(Integer devueltas) {
        this.devueltas = devueltas;
    }

    public Date getFIni() {
        return fIni;
    }

    public void setFIni(Date fIni) {
        this.fIni = fIni;
    }

    public Date getFFin() {
        return fFin;
    }

    public void setFFin(Date fFin) {
        this.fFin = fFin;
    }

    public Short getUdsEquipo() {
        return udsEquipo;
    }

    public void setUdsEquipo(Short udsEquipo) {
        this.udsEquipo = udsEquipo;
    }

    public Short getEstado() {
        return estado;
    }

    public void setEstado(Short estado) {
        this.estado = estado;
    }

    public String getResumen() {
        return resumen;
    }

    public void setResumen(String resumen) {
        this.resumen = resumen;
    }

    public String getDuracion() {
        return duracion;
    }

    public void setDuracion(String duracion) {
        this.duracion = duracion;
    }

    public short getCuartos() {
        return cuartos;
    }

    public void setCuartos(short cuartos) {
        this.cuartos = cuartos;
    }

    public MCarta getMcarta() {
        return mCarta;
    }

    public void setMcarta(MCarta mCarta) {
        this.mCarta = mCarta;
    }

    public Collection<CartaEquipo> getCartaEquipoCollection() {
        return cartaEquipoCollection;
    }

    public void setCartaEquipoCollection(Collection<CartaEquipo> cartaEquipoCollection) {
        this.cartaEquipoCollection = cartaEquipoCollection;
    }

    public int getEfectoTipo() {
        return efecto_tipo;
    }

    public void setEfectoTipo(int valor) {
        this.efecto_tipo = valor;
    }

    public int getEfectoValor() {
        return efecto_valor;
    }

    public void setEfectoValor(int valor) {
        this.efecto_valor = valor;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String valor) {
        this.descripcion = valor;
    }


    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Carta)) {
            return false;
        }
        Carta other = (Carta) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bitoon.basketdudes.jpa.Carta[id=" + id + "][mCarta="+ mCarta.toString() +"]";
    }

}
